package com.spddr.pmos.domain;

import cn.seqdata.jpa.JpaAuditableObject;

import com.spddr.pmos.jpa.City;
import com.spddr.pmos.jpa.Company;
import com.spddr.pmos.jpa.Customer;
import com.spddr.pmos.jpa.District;
import com.spddr.pmos.jpa.Grid;
import com.spddr.pmos.jpa.HydrologyStation;
import com.spddr.pmos.jpa.Line;
import com.spddr.pmos.jpa.Plant;
import com.spddr.pmos.jpa.Province;
import com.spddr.pmos.jpa.RainStation;
import com.spddr.pmos.jpa.Reservoir;
import com.spddr.pmos.jpa.River;
import com.spddr.pmos.jpa.Substation;
import com.spddr.pmos.jpa.TelemetryStation;
import com.spddr.pmos.jpa.Transformer;
import com.spddr.pmos.jpa.Transmission;
import com.spddr.pmos.jpa.Unit;
import com.spddr.pmos.jpa.UsagePoint;
import com.spddr.pmos.jpa.UsagePointGroup;
import com.spddr.pmos.jpa.WeatherStation;

public enum TreeLevel {
	Province(1, "省市", Province.class, "university"), //
	City(2, "地区", City.class, "university"), //
	District(3, "区县", District.class, "university"), //

	Grid(11, "电网公司", Grid.class, "balance-scale"), //
	Company(12, "发电公司", Company.class, "building"), //
	Customer(13, "电力客户", Customer.class, "user"), //

	Plant(101, "发电厂", Plant.class, "birthday-cake"), //
	Unit(1001, "机组", Unit.class, "empire"), //

	Substation(201, "变电站", Substation.class, "ioxhost"), //
	Transformer(2001, "变压器", Transformer.class, "mars-double"), //
	Line(2002, "出线", Line.class, "sliders"), //

	Transmission(301, "联络线", Transmission.class, "exchange"), //

	River(401, "流域", River.class, "code-fork"), //
	Reservoir(4001, "水库", Reservoir.class, "ship"), //

	UsageGroup(11001, "汇总关口", UsagePointGroup.class, "tags"), //
	UsagePoint(11000, "计量点", UsagePoint.class, "tag"), //

	Telemetry(12000, "遥测站", TelemetryStation.class, "map-marker"), //
	Hydrology(12001, "水文站", HydrologyStation.class, "map-marker"), //
	Rain(12002, "雨量站", RainStation.class, "map-marker"), //
	Weather(12003, "气象站", WeatherStation.class, "map-marker"), //

	Unknown(0, "未知", JpaAuditableObject.class, "");

	public final int id;
	public final String name;
	public final Class<? extends JpaAuditableObject> clazz;
	public final String icon;

	TreeLevel(int id, String name, Class<? extends JpaAuditableObject> clazz, String icon) {
		this.id = id;
		this.name = name;
		this.clazz = clazz;
		this.icon = icon;
	}

	public static TreeLevel valueOf(int id) {
		for (TreeLevel level : values()) {
			if (level.id == id)
				return level;
		}
		return Unknown;
	}

	public static TreeLevel valueOf(Class<?> cls) {
		for (TreeLevel level : values()) {
			if (null != level.clazz && cls.isAssignableFrom(level.clazz))
				return level;
		}
		return Unknown;
	}
}
